/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package library.impl;

import library.Books;
import library.Library;
import library.LibraryPackage;
import library.RentRecords;
import library.Renters;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc --> An implementation of the model object '<em><b>Library</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link library.impl.LibraryImpl#getBooks <em>Books</em>}</li>
 * <li>{@link library.impl.LibraryImpl#getRenters <em>Renters</em>}</li>
 * <li>{@link library.impl.LibraryImpl#getRentRecords <em>Rent Records</em>}</li>
 * <li>{@link library.impl.LibraryImpl#getId <em>Id</em>}</li>
 * </ul>
 * </p>
 * 
 * @generated
 */
public class LibraryImpl extends EObjectImpl implements Library {
	/**
	 * The cached value of the '{@link #getBooks() <em>Books</em>}'
	 * containment reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getBooks()
	 * @generated
	 * @ordered
	 */
	protected Books books;

	/**
	 * The cached value of the '{@link #getRenters() <em>Renters</em>}'
	 * containment reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getRenters()
	 * @generated
	 * @ordered
	 */
	protected Renters renters;

	/**
	 * The cached value of the '{@link #getRentRecords() <em>Rent Records</em>}'
	 * containment reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getRentRecords()
	 * @generated
	 * @ordered
	 */
	protected RentRecords rentRecords;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final long ID_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute. <!--
	 * begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected long id = ID_EDEFAULT;

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected LibraryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	protected EClass eStaticClass() {
		return LibraryPackage.Literals.LIBRARY;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Books getBooks() {
		return books;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public NotificationChain basicSetBooks(Books newBooks,
			NotificationChain msgs) {
		Books oldBooks = books;
		books = newBooks;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this,
					Notification.SET, LibraryPackage.LIBRARY__BOOKS, oldBooks,
					newBooks);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setBooks(Books newBooks) {
		if (newBooks != books) {
			NotificationChain msgs = null;
			if (books != null)
				msgs = ((InternalEObject) books).eInverseRemove(this,
						EOPPOSITE_FEATURE_BASE - LibraryPackage.LIBRARY__BOOKS,
						null, msgs);
			if (newBooks != null)
				msgs = ((InternalEObject) newBooks).eInverseAdd(this,
						EOPPOSITE_FEATURE_BASE - LibraryPackage.LIBRARY__BOOKS,
						null, msgs);
			msgs = basicSetBooks(newBooks, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.LIBRARY__BOOKS, newBooks, newBooks));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Renters getRenters() {
		return renters;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public NotificationChain basicSetRenters(Renters newRenters,
			NotificationChain msgs) {
		Renters oldRenters = renters;
		renters = newRenters;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this,
					Notification.SET, LibraryPackage.LIBRARY__RENTERS,
					oldRenters, newRenters);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setRenters(Renters newRenters) {
		if (newRenters != renters) {
			NotificationChain msgs = null;
			if (renters != null)
				msgs = ((InternalEObject) renters).eInverseRemove(this,
						EOPPOSITE_FEATURE_BASE
								- LibraryPackage.LIBRARY__RENTERS, null, msgs);
			if (newRenters != null)
				msgs = ((InternalEObject) newRenters).eInverseAdd(this,
						EOPPOSITE_FEATURE_BASE
								- LibraryPackage.LIBRARY__RENTERS, null, msgs);
			msgs = basicSetRenters(newRenters, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.LIBRARY__RENTERS, newRenters, newRenters));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public RentRecords getRentRecords() {
		return rentRecords;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public NotificationChain basicSetRentRecords(RentRecords newRentRecords,
			NotificationChain msgs) {
		RentRecords oldRentRecords = rentRecords;
		rentRecords = newRentRecords;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this,
					Notification.SET, LibraryPackage.LIBRARY__RENT_RECORDS,
					oldRentRecords, newRentRecords);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setRentRecords(RentRecords newRentRecords) {
		if (newRentRecords != rentRecords) {
			NotificationChain msgs = null;
			if (rentRecords != null)
				msgs = ((InternalEObject) rentRecords).eInverseRemove(this,
						EOPPOSITE_FEATURE_BASE
								- LibraryPackage.LIBRARY__RENT_RECORDS, null,
						msgs);
			if (newRentRecords != null)
				msgs = ((InternalEObject) newRentRecords).eInverseAdd(this,
						EOPPOSITE_FEATURE_BASE
								- LibraryPackage.LIBRARY__RENT_RECORDS, null,
						msgs);
			msgs = basicSetRentRecords(newRentRecords, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.LIBRARY__RENT_RECORDS, newRentRecords,
					newRentRecords));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public long getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setId(long newId) {
		long oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.LIBRARY__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case LibraryPackage.LIBRARY__BOOKS:
			return basicSetBooks(null, msgs);
		case LibraryPackage.LIBRARY__RENTERS:
			return basicSetRenters(null, msgs);
		case LibraryPackage.LIBRARY__RENT_RECORDS:
			return basicSetRentRecords(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case LibraryPackage.LIBRARY__BOOKS:
			return getBooks();
		case LibraryPackage.LIBRARY__RENTERS:
			return getRenters();
		case LibraryPackage.LIBRARY__RENT_RECORDS:
			return getRentRecords();
		case LibraryPackage.LIBRARY__ID:
			return new Long(getId());
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case LibraryPackage.LIBRARY__BOOKS:
			setBooks((Books) newValue);
			return;
		case LibraryPackage.LIBRARY__RENTERS:
			setRenters((Renters) newValue);
			return;
		case LibraryPackage.LIBRARY__RENT_RECORDS:
			setRentRecords((RentRecords) newValue);
			return;
		case LibraryPackage.LIBRARY__ID:
			setId(((Long) newValue).longValue());
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public void eUnset(int featureID) {
		switch (featureID) {
		case LibraryPackage.LIBRARY__BOOKS:
			setBooks((Books) null);
			return;
		case LibraryPackage.LIBRARY__RENTERS:
			setRenters((Renters) null);
			return;
		case LibraryPackage.LIBRARY__RENT_RECORDS:
			setRentRecords((RentRecords) null);
			return;
		case LibraryPackage.LIBRARY__ID:
			setId(ID_EDEFAULT);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case LibraryPackage.LIBRARY__BOOKS:
			return books != null;
		case LibraryPackage.LIBRARY__RENTERS:
			return renters != null;
		case LibraryPackage.LIBRARY__RENT_RECORDS:
			return rentRecords != null;
		case LibraryPackage.LIBRARY__ID:
			return id != ID_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (id: ");
		result.append(id);
		result.append(')');
		return result.toString();
	}

} // LibraryImpl
